/**
 * Copyright  2016
 *
 * 	All right reserved.
 *
 *	Created on  2016年3月8日 上午10:41:38
 * 
 */
package com.hongxinguoji.manager.site.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hongxinguoji.manager.common.util.EasyUIDataGridResult;
import com.hongxinguoji.manager.site.mapper.HxSiteMapper;
import com.hongxinguoji.manager.site.pojo.HxSite;
import com.hongxinguoji.manager.site.pojo.HxSiteExample;
import com.hongxinguoji.manager.site.service.ISiteService;

/**
 * @author liuh
 *
 */
@Service
public class SiteServiceImpl implements ISiteService {
	
	@Resource
	private HxSiteMapper siteMapper; 

	@Override
	public EasyUIDataGridResult getSiteList(Integer page, Integer rows) {
		EasyUIDataGridResult result = new EasyUIDataGridResult();
		// 分页处理
		PageHelper.startPage(page, rows);
		HxSiteExample example = new HxSiteExample();
		List<HxSite> list = siteMapper.selectByExample(example);
		PageInfo<HxSite> pageInfo = new PageInfo<>(list);
		result.setTotal(pageInfo.getTotal());
		result.setRows(list);
		return result;
	}

	@Override
	public void addSite(HxSite hxSite) {
		siteMapper.insertSite(hxSite);
	}

	@Override
	public void updateSite(HxSite site) {
		siteMapper.updateByPrimaryKey(site);
	}

	@Override
	public void deleteSite(String ids) {
		siteMapper.deleteByPrimaryKey(ids);
	}

}
